package com.topone.permission.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *@author XiaZhentao
 *@date  2018/7/30  20:41
 */
@Data
@AllArgsConstructor
//@NoArgsConstructor
public class Result<T> {
	
	private String code;
	private String msg;
	private T data;
	
	public Result(String code, String msg) {
		this.code=code;
		this.msg = msg;
	}
	public Result() {
		
	}

	public Result(String code) {
		this.code=code;
	}
	
	/**
	 *  成功时候的调用
	 * */
	public static  <T> Result<T> success(T data){
		return new Result<T>("2000","",data);
	}
	
	public static  <T> Result<T> success(){
		return new Result<T>("2000","",null);
	}
	
	/**
	 *  失败时候的调用
	 * */
	public static  <T> Result<T> error(String code,String msg){
		return new Result<T>(code,msg);
	}
	
	


}
